import { DataTypes } from 'sequelize'
const seq = require('../db/seq')

const CourseVideoModels: any = seq.define('course_video', {
  id: {
    autoIncrement: true,
    type: DataTypes.INTEGER,
    allowNull: false,
    primaryKey: true,
    comment: "视频的id"
  },
  course_id: {
    type: DataTypes.INTEGER,
    allowNull: false,
    comment: "连接课程表",
    references: {
      model: 'course',
      key: 'id'
    }
  },
  name: {
    type: DataTypes.STRING(45),
    allowNull: false,
    comment: "视频名称"
  },
  video: {
    type: DataTypes.STRING(255),
    allowNull: false,
    comment: "视频的url地址"
  }
}, {
  tableName: 'course_video',
  timestamps: false,
  indexes: [
    {
      name: "PRIMARY",
      unique: true,
      using: "BTREE",
      fields: [
        { name: "id" },
      ]
    },
    {
      name: "FK_video_course_id_idx",
      using: "BTREE",
      fields: [
        { name: "course_id" },
      ]
    },
  ]
});

module.exports = CourseVideoModels